/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Yongke
 */
import java.util.Vector;

public class Room {
    private String roomName;
    private int categoryID;
    private Vector<String> banUser;
    private String owner;
    private Vector<String> activeUser;
    private boolean persist;

    public Room() {
        banUser = new Vector<String>();
        activeUser = new Vector<String>();
    }

    public Room(String NamaRoom, String Owner, int Kategori)
    {
        roomName = NamaRoom;
        owner = Owner;
        categoryID = Kategori;
        banUser = new Vector<String>();
        activeUser = new Vector<String>();
        persist = false;
    }

    public String getRoomName(){return roomName;}
    public int getCategoryID(){return categoryID;}
    public Vector<String> getBanList(){return banUser;}
    public String getOwner(){return owner;}
    public Vector<String> getActiveUser(){return activeUser;}
    public boolean getPersist(){return persist;}

    public void userban(String username)
    {
        if (activeUser.contains(username))
            kickUser(username);
        banUser.add(username);
    }
    public void userunban(String username)
    {
        banUser.remove(username);
    }
    public boolean isuserban(String username){return banUser.contains(username);}
    public boolean joinRoom(String username)
    {
        if (banUser.contains(username))
        {
            return false;
        }
        else
        {
            if (!activeUser.contains(username))
            {
                activeUser.add(username);
            }
            return true;
        }
    }

    public void kickUser(String username)
    {
        activeUser.remove(username);
    }

    public void setOwner(String username)
    {
        owner = username;
    }

    public void setPersist(boolean p)
    {
        persist = p;
    }

    public boolean isUserInside(String username)
    {
        return activeUser.contains(username);
    }
}
